import React from 'react';
import ReactDOM from 'react-dom';
import store from './store'
import { Provider, connect } from './myreact-redux'
// {getState,subscribe,dispatch}
class App extends React.Component {

  render() {
    console.log(this.props.qqq)
    let { color, count, dispatch } = this.props;
    return <div className=''>
      <h1 style={{ color: color }}>{count}</h1>
      <button onClick={() => {
        dispatch({ type: "changeCount", count: count + 10 })
      }}>+</button><button onClick={() => {
        dispatch(function (dispatch) {
          setTimeout(() => {
            dispatch({ type: "changeColor", color: 'blue' })
          }, 2000);
        })
      }}>颜色</button>
    </div>;
  }
}
App = connect(state => {
  return {
    count: state.countState.count,
    color: state.colorState.color
  }
}, dispatch => {
  return {
    dispatch
  }
})(App)

ReactDOM.render(<Provider store={store}>
  <App />
</Provider>, document.getElementById('root'))